{include file="common/head_s"/}
<style type="text/css">
body,html{ background: #fff }
.layui-table-view{ margin: 0px!important; }
</style>
<div class="main"> 
    <div class="pd15"><table class="layui-table layui-hide" id="list" lay-filter="list"></table></div>
</div> 
<script type="text/html" id="lvte">
   {{d.rate}} %
</script>
<script type="text/html" id="open">
    <input type="checkbox" name="open" value="{{d.id}}" lay-skin="switch" lay-text="开启|关闭" lay-filter="open" {{ d.open == 1 ? 'checked' : '' }}>
</script> 
<script type="text/html" id="username">{$username}</script> 
<script type="text/html" id="mobile">{$mobile}</script>  
<script src="/static/plugins/layui/layui.js"></script> 
<script>
    layui.use(['table','form'], function() {
        var table = layui.table,form = layui.form,$ = layui.jquery;
        userid="{$userid}"; 
        var tableIn = table.render({
            id: 'ad',
            elem: '#list',
            url: '{:url("index")}',
            method: 'post',
            page:true,
            cols: [[ 
                // {field: 'id', title: '{:lang("id")}',align: 'center', width: 80, fixed: true},
                {field: 'title', title: '通道名称',align: 'center', width: 120, fixed: true},
                {field: 'cionname', title: '币种',align: 'center', width: 128, fixed: true},
                {field: 'price', title: '单价',align: 'center', width: 100, fixed: true},
                {field: 'rate', title: '通道手续费', align: 'center', width:100,fixed: true,templet: '#lvte'},
                {field: 'shopname', title: '所属商城',align: 'center',width:156}, 
                {field: 'money_total', title: '累计收款',align: 'center',width:130},
                {field: 'username', title: '联系人', align: 'center', width:110,templet: '#username'},
                {field: 'mobile', title: '联系方式', align: 'center', width:138,templet: '#mobile'}, 
                {field: 'addtime', title: '开通时间',width: 150}, 
                {field: 'open', align: 'center', title: '通道状态', width: 100, toolbar: '#open'}, 
            ]],
            limit:10,where: {userid:userid}
        });
        form.on('switch(open)', function(obj){
            loading =layer.load(1, {shade: [0.1,'#fff']});
            var id = this.value;
            var open = obj.elem.checked===true?1:0;
            $.post('{:url("channelState")}',{'id':id,'open':open},function (res) {
                layer.close(loading);
                if (res.status==1) {
                    layer.msg(res.msg,{time:1000,icon:1},function(){
                        tableIn.reload();
                    }); 
                }else{
                    layer.msg(res.msg,{time:1000,icon:2});
                    return false;
                }
            })
        });  
    })
</script> 
</body>
</html>